package com.koudai.finance.web;

import lombok.extern.slf4j.Slf4j;

/**
 * @Description: 用户上下文
 * @author: ls
 * @Date: 2020/7/21 14:25
 */
@Slf4j
public class UserContext {

    private static final ThreadLocal<Integer> USER_ID_HOLDER = new ThreadLocal<>();

    private UserContext() {
    }

    public static Integer getUserId() {
        return USER_ID_HOLDER.get();
    }

    public static void clear() {
        USER_ID_HOLDER.remove();
    }

    public static void setUserId(Integer userId) {
        USER_ID_HOLDER.set(userId);
    }

}
